package com.rockcent.helper;

import com.rockcent.mall.lib.domain.enumclass.MerchantDeductionsType;
import com.rockcent.mall.lib.domain.enumclass.MerchantPayType;

import java.util.Random;

/**
 * Created by zhangjh on 2017/3/29.
 */
public enum MerchantFundFlowrHelper {
    SINGLETON;

    public String createMerchantFundSeqNo(MerchantPayType rechargePayType) {

        int flag = 0;
        if (rechargePayType != null) flag = rechargePayType.getValue().length();
        return getSeqNo(flag);
    }


    public String createMerchantFundSeqNo(MerchantDeductionsType deductionsType) {
        int flag = 0;
        if (deductionsType != null) flag = deductionsType.getValue().length();
        return getSeqNo(flag);
    }

    private String getSeqNo(int flag) {
        String format = String.format("%02d", flag);
        Random random = new Random();
        String idRandom = String.format("%04d", random.nextInt(10000));
        return String.format("%s%s%d", idRandom, format, System.currentTimeMillis());
    }
}
